package ace.tool.generate.code.impl.service.model.input;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author caspar
 * @date 2024/1/11 9:19
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GenerateInput implements Serializable {

  /**
   * 项目的实体.
   */
  @NotNull
  @NotEmpty
  private List<GenerateModelInput> models = new ArrayList<>();

  /**
   * 项目的实体配置文件目录路径.
   */
  private List<String> modelFileDirPaths = new ArrayList<>();

  /**
   * 删除项目目录
   */
  @Builder.Default
  private Boolean deleteModuleProjectRootDir = true;

  /**
   * 项目目录
   */
  @Builder.Default
  private String projectRootDir = "./target/generated-projects";

  /**
   * 项目名前缀 example: ace-module-demo-sms code package path: ace.module.demo.sms project name:
   * ace-module-dem-sms-projects,ace-module-dem-sms-api,ace-module-dem-sms-core-starter,ace-module-dem-sms-sdk-starter
   */
  @Builder.Default
  private String projectNamePrefix = "ace-module";

  /**
   * 项目命名空间 example: demo-sms code package path: ace.module.demo.sms project name:
   * ace-module-dem-sms-projects,ace-module-dem-sms-api,ace-module-dem-sms-core-starter,ace-module-dem-sms-sdk-starter
   */
  @Builder.Default
  private String projectName = "";

  @Builder.Default
  private String projectDisplayName = "";

  /**
   * 项目名后缀
   */
  @Builder.Default
  private String projectNameSuffix = "";

  /**
   * api项目名后缀
   */
  @Builder.Default
  private String apiProjectNameSuffix = "-api";

  /**
   * core项目名后缀
   */
  @Builder.Default
  private String coreProjectNameSuffix = "-core-starter";

  /**
   * sdk项目名后缀.
   */
  @Builder.Default
  private String sdkProjectNameSuffix = "-sdk-starter";

  @Builder.Default
  private String sdkConstantPackagePrefix = "sdk.core.constant";
  /**
   * sdk项目 constant名
   */
  @Builder.Default
  private String sdkConstantName = "Sdk";

  /**
   * sdk项目 constant后缀
   */
  @Builder.Default
  private String sdkConstantNameSuffix = "Constant";

  /**
   * api 类名后缀
   */
  @Builder.Default
  private String apiClassNameSuffix = "Api";

  /**
   * api 类前缀 api 类完全名： rootPackageFullName + apiClassPackagePrefix + apiClassName =
   * ace.module.demo.api.DemoApi rootPackageFullName: ace.module.demo apiClassPackagePrefix:
   * .core.impl.dao.entity. apiClassName: DemoEntity
   */
  @Builder.Default
  private String apiClassPackagePrefix = "api";

  /**
   * entity 类名后缀
   */
  @Builder.Default
  private String entityClassNameSuffix = "";

  @Builder.Default
  private String deleteFlagFieldName = "deleteFlag";
  @Builder.Default
  private String updateTimeFieldName = "updateTime";
  @Builder.Default
  private String createTimeFieldName = "createTime";
  @Builder.Default
  private String rowVersionFieldName = "rowVersion";
  @Builder.Default
  private Boolean enableDeleteFlagField = true;
  @Builder.Default
  private Boolean enableUpdateTimeField = true;
  @Builder.Default
  private Boolean enableCreateTimeField = true;
  @Builder.Default
  private Boolean enableRowVersionField = true;

  /**
   * entity 类前缀 entity 类完全名： rootPackageFullName + entityClassPackagePrefix + entityClassName =
   * ace.module.demo.core.impl.dao.entity.DemoEntity rootPackageFullName: ace.module.demo
   * entityClassPackagePrefix: .core.impl.dao.entity. entityClassName: DemoEntity
   */
  @Builder.Default
  private String entityClassPackagePrefix = "core.impl.dao.entity";

  /**
   * graphql 的资源配置文件
   */
  @Builder.Default
  private String graphqlSchemaFileName = "schema.graphqls";

  /**
   * graphql auto schema 的资源配置文件
   */
  @Builder.Default
  private String graphqlAutoSchemaFileName = "schema-auto-generate.graphqls";

  /**
   * graphql 的资源配置文件 前缀路径
   */
  @Builder.Default
  private String graphqlSchemaRootDirPrefix = "/graphql";

  /**
   * graphql input 的资源配置文件 前缀路径
   */
  @Builder.Default
  private String graphqlSchemaInputRootDirPrefix = "/graphql/model/input";

  /**
   * graphql dto 的资源配置文件 前缀路径
   */
  @Builder.Default
  private String graphqlSchemaDtoRootDirPrefix = "/graphql/model/dto";

  /**
   * api 类名后缀
   */
  @Builder.Default
  private String apiImplClassNameSuffix = "ApiImpl";

  /**
   * api 类包路径前缀
   */
  @Builder.Default
  private String apiImplClassPackagePrefix = "core.impl.api.impl";

  /**
   * restRpcController 类名后缀
   */
  @Builder.Default
  private String restRpcControllerClassNameSuffix = "RpcController";

  /**
   * restRpcController 类包路径前缀
   */
  @Builder.Default
  private String restRpcControllerClassPackagePrefix = "core.impl.controller.rest.rpc";

  /**
   * restAdminController 类名后缀
   */
  @Builder.Default
  private String restAdminControllerClassNameSuffix = "AdminController";

  /**
   * restAdminController 类包路径前缀
   */
  @Builder.Default
  private String restAdminControllerClassPackagePrefix = "core.impl.controller.rest.admin";

  /**
   * restTenantAdminController 类名后缀
   */
  @Builder.Default
  private String restTenantAdminControllerClassNameSuffix = "TenantAdminController";

  /**
   * restTenantAdminController 类包路径前缀
   */
  @Builder.Default
  private String restTenantAdminControllerClassPackagePrefix = "core.impl.controller.rest.admin.tenant";

  /**
   * graphqlAdminController 类的schema扩展后缀
   */
  @Builder.Default
  private String graphqlAdminControllerSchemaExtendMappingSuffix = "Admin";

  /**
   * graphqlAdminController 类名后缀
   */
  @Builder.Default
  private String graphqlAdminControllerClassNameSuffix = "AdminGraphql";

  /**
   * graphqlAdminController 类包路径前缀
   */
  @Builder.Default
  private String graphqlAdminControllerClassPackagePrefix = "core.impl.controller.graphql.admin";

  /**
   * repositoryScanner 类包路径前缀
   */
  @Builder.Default
  private String repositoryScannerClassPackagePrefix = "core.impl.dao.repository";

  /**
   * repository 类名后缀
   */
  @Builder.Default
  private String repositoryClassNameSuffix = "Repository";

  /**
   * repository 类包路径前缀
   */
  @Builder.Default
  private String repositoryClassPackagePrefix = "core.impl.dao.repository";

  /**
   * aggregate 类名后缀
   */
  @Builder.Default
  private String aggregateClassNameSuffix = "Aggregate";

  /**
   * aggregate 类包路径前缀
   */
  @Builder.Default
  private String aggregateClassPackagePrefix = "core.impl.dao.aggregate";

  /**
   * aggregate impl 类名后缀
   */
  @Builder.Default
  private String aggregateImplClassNameSuffix = "AggregateImpl";

  /**
   * aggregate impl 类包路径前缀
   */
  @Builder.Default
  private String aggregateImplClassPackagePrefix = "core.impl.dao.aggregate.impl";

  /**
   * manager 类名后缀
   */
  @Builder.Default
  private String managerClassNameSuffix = "Manager";

  /**
   * manager 类包路径前缀
   */
  @Builder.Default
  private String managerClassPackagePrefix = "core.impl.manager";

  /**
   * manager implement 类名后缀
   */
  @Builder.Default
  private String managerImplClassNameSuffix = "ManagerImpl";

  /**
   * manager implement 类包路径前缀
   */
  @Builder.Default
  private String managerImplClassPackagePrefix = "core.impl.manager.impl";

  /**
   * initListener 类名后缀
   */
  @Builder.Default
  private String initListenerClassNameSuffix = "InitListener";

  /**
   * initListener 类包路径前缀
   */
  @Builder.Default
  private String initListenerClassPackagePrefix = "core.impl.listener";

  /**
   * initService 类名后缀
   */
  @Builder.Default
  private String initServiceClassNameSuffix = "InitService";

  /**
   * initService 类包路径前缀
   */
  @Builder.Default
  private String initServiceClassPackagePrefix = "core.impl.service";

  /**
   * InitServiceImpl 类名后缀
   */
  @Builder.Default
  private String initServiceImplClassNameSuffix = "InitServiceImpl";

  /**
   * InitServiceImpl 类包路径前缀
   */
  @Builder.Default
  private String initServiceImplClassPackagePrefix = "core.impl.service.impl";

  /**
   * dto 类名后缀
   */
  @Builder.Default
  private String dtoClassNameSuffix = "Dto";

  /**
   * api 类前缀 api 类完全名： rootPackageFullName + apiClassPackagePrefix + apiClassName =
   * ace.module.demo.api.model.dto.DemoDto rootPackageFullName: ace.module.demo
   * dtoClassPackagePrefix: .api.model.dto. dtoClassName: DemoDto
   */
  @Builder.Default
  private String dtoClassPackagePrefix = "api.model.dto";

  @Builder.Default
  private String enumClassPackagePrefix = "api.enums";
  @Builder.Default
  private String constantClassPackagePrefix = "api.constant";
  @Builder.Default
  private String constantClassNameSuffix = "Constant";
  @Builder.Default
  private String authorityConstantClassPackagePrefix = "api.constant";
  @Builder.Default
  private String authorityConstantClassNameSuffix = "AuthorityConstant";
  @Builder.Default
  private String feignApiClassNameSuffix = "FeignApi";
  @Builder.Default
  private String feignApiClassPackagePrefix = "sdk.core.feign";
  @Builder.Default
  private String feignClassNameSuffix = "Feign";
  @Builder.Default
  private String feignClassPackagePrefix = "sdk.core.feign.impl";

  /**
   * {@link FeignClient} 配置前缀 example:ace.cloud.openfeign.client.module.demo-sms.application
   */
  @Builder.Default
  private String feignClientConfigPrefix = "spring.cloud.openfeign.client.config";

  @Builder.Default
  private String sdkFeignScannerClassPackagePrefix = "sdk.core.feign.impl";
  @Builder.Default
  private String sdkFeignScannerClassNameSuffix = "FeignScanner";
  @Builder.Default
  private String sdkAutoConfigClassPackagePrefix = "sdk.autoconfig";

  /**
   * sdk 项目 自动配置类名后缀 DemoSmsSdkAutoConfig
   */
  @Builder.Default
  private String sdkAutoConfigClassSuffix = "SdkAutoConfig";

  /**
   * core 项目 自动配置类名相对路径前缀
   */
  @Builder.Default
  private String coreAutoConfigClassPackagePrefix = "core.autoconfig";

  /**
   * core 项目 自动配置类名后缀 DemoSmsCoreAutoConfig
   */
  @Builder.Default
  private String coreAutoConfigClassSuffix = "CoreAutoConfig";

  /**
   * core 项目 启动扫描定位类 的包路径前缀
   */
  @Builder.Default
  private String coreBootstrapScannerClassPackagePrefix = "core.impl";

  /**
   * core 项目 启动扫描定位类 example: ace.module.demo.sms.core.impl.DemoSmsBoostrapScanner;
   */
  @Builder.Default
  private String coreBootstrapScannerClassNameSuffix = "CoreBootstrapScanner";

  /**
   * core 项目 属性配置类 的包路径前缀
   */
  @Builder.Default
  private String corePropertiesClassPackagePrefix = "core.impl.properties";

  /**
   * core 项目 属性配置类,example: DemoSmsProperties
   */
  @Builder.Default
  private String corePropertiesClassNameSuffix = "CoreProperties";

  @Builder.Default
  private String coreConstantClassPackagePrefix = "core.impl.constant";
  @Builder.Default
  private String coreConstantClassNameSuffix = "CoreConstant";

  /**
   * liquibase 的init-table.xml 文件名
   */
  @Builder.Default
  private String liquibaseInitTableFileName = "init-table.xml";

  /**
   * liquibase 的init-table.xml 文件的相对根路径
   */
  @Builder.Default
  private String liquibaseInitTableFileRootDir = "/db/changelog";

  /**
   * liquibase table.xml 文件的相对根路径
   */
  @Builder.Default
  private String liquibaseTableFileRootDir = "/db/changelog/tables";

  /**
   * 测试目录相对根路径
   */
  @Builder.Default
  private String testRootPackagePrefix = "test";

  /**
   * api 的测试类后缀
   */
  @Builder.Default
  private String testApiClassNameSuffix = "ApiTest";

  /**
   * api 的测试类包路径相对位置
   */
  @Builder.Default
  private String testApiClassPackagePrefix = "test.test.api";

  /**
   * startupTest 的测试类包路径相对位置
   */
  @Builder.Default
  private String testStartUpClassPackagePrefix = "test.test";

  /**
   * graphql admin controller 的测试类后缀
   */
  @Builder.Default
  private String testGraphqlAdminControllerClassNameSuffix = "AdminGraphqlTest";

  /**
   * graphql admin controller 的测试类包路径相对位置
   */
  @Builder.Default
  private String testGraphqlAdminControllerClassPackagePrefix =
      "test.test.core.controller.graphql.admin";

  /**
   * rest admin controller 的测试类后缀
   */
  @Builder.Default
  private String testRestAdminControllerClassNameSuffix = "AdminControllerTest";

  /**
   * rest admin controller 的测试类包路径相对位置
   */
  @Builder.Default
  private String testRestAdminControllerClassPackagePrefix = "test.test.core.controller.rest.admin";

  /**
   * ui 项目名称
   */
  @Builder.Default
  private String uiProjectName = "ace-platform-ui-antd";

  @Builder.Default
  private String uiCoreDirRelativePath = "/src/core";

  @Builder.Default
  private String uiMockDirRelativePath = "/mock";

  @Builder.Default
  private String uiEnumClassPackagePrefix = "/generated/enums";

  /**
   * ui response 类名后缀
   */
  @Builder.Default
  private String uiResponseClassNameSuffix = "Response";

  @Builder.Default
  private String uiResponseClassPackagePrefix = "/generated/types/model/response";

  @Builder.Default
  private String uiMockServerApiClassNameSuffix = "MockServerApi";

  @Builder.Default
  private String uiMockServerApiClassPackagePrefix = "";

  @Builder.Default
  private String uiMockServerApiClassRootPackageFullNamePrefix = "/mock/generated";

  @Builder.Default
  private String uiMockServerApiIndexClassNameSuffix = "";

  @Builder.Default
  private String uiMockServerApiIndexClassName = "index";

  @Builder.Default
  private String uiMockServerApiIndexClassPackagePrefix = "";

  @Builder.Default
  private String uiMockServerApiIndexClassRootPackageFullNamePrefix = "/mock/generated";

  @Builder.Default
  private String uiViewListClassNameSuffix = "List";

  @Builder.Default
  private String uiApiConfigClassNameSuffix = "AdminApiConfig";

  @Builder.Default
  private String uiApiConfigClassPackagePrefix = "/generated/apiconfig";

  @Builder.Default
  private String uiServerApiClassNameSuffix = "AdminServerApi";

  @Builder.Default
  private String uiServerApiClassPackagePrefix = "/generated/serverapi/admin";

  @Builder.Default
  private String uiServiceClassNameSuffix = "AdminService";

  @Builder.Default
  private String uiServiceClassPackagePrefix = "/generated/service/admin";

  @Builder.Default
  private List<String> uiFrameworkDirs =
      new ArrayList<>(
          Arrays.asList(
              "/enums",
              "/service",
              "/serverapi",
              "/apiconfig",
              "/types/model/response",
              "/types/model/dto"));
}
